// https://www.luogu.com.cn/problem/P1910
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
#define MAX_SIZE 1005
#define MAXN 105

int n, m, x;
int a, b, c;
// int a[MAXN], b[MAXN], c[MAXN];
int f[2][MAX_SIZE][MAX_SIZE];  // f[i][j][k]
/*
    f[i][j] = max(f[i - 1][j], f[i][j - b[i]] + a[i])
    f[i][j][k] = max(f[i - 1][j][k], f[i][j - b[i]][k - c[i]] + a[i])
*/

int main() {
    scanf("%d%d%d", &n, &m, &x);
    // rf(i, n) scanf("%d%d%d", a + i, b + i, c + i);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d%d", &a, &b, &c);
        for (int j = 1; j <= m; ++j) {
            for (int k = 1; k <= x; ++k) {
                f[i & 1][j][k] = f[i - 1 & 1][j][k];
                // if (j >= b[i] && k >= c[i])
                //     f[i & 1][j][k] = max(f[i & 1][j][k], f[i - 1 & 1][j - b[i]][k - c[i]] + a[i]);
                if (j >= b && k >= c)
                    f[i & 1][j][k] = max(f[i & 1][j][k], f[i - 1 & 1][j - b][k - c] + a);
            }
        }
    }

    printf("%d", f[n & 1][m][x]);
}
